/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pl.edu.agh.io.gpstracker.model;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author wkedzior
 */
@Entity
@Table(name = "tracksequence")
@NamedQueries({
    @NamedQuery(name = "Tracksequence.findAll", query = "SELECT t FROM Tracksequence t"),
    @NamedQuery(name = "Tracksequence.findById", query = "SELECT t FROM Tracksequence t WHERE t.id = :id")})
public class Tracksequence implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Long id;
    @JoinColumn(name = "places_id", referencedColumnName = "id")
    @ManyToOne
    private Places places;
    @JoinColumn(name = "track_id", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Track track;
    @Column(name = "track_id",  insertable = false, updatable = false)
    private Long trackId; 
    @JoinColumn(name = "node_id", referencedColumnName = "id")
    @ManyToOne(optional = false, fetch=FetchType.EAGER)
    private Node node;

	public Tracksequence() {
    }

	public Tracksequence(Long id) {
        this.id = id;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Tracksequence)) {
            return false;
        }
        Tracksequence other = (Tracksequence) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    public Long getId() {
        return id;
    }

    public Node getNode() {
        return node;
    }

  
    public Places getPlaces() {
        return places;
    }

    public Track getTrack() {
        return track;
    }

    public Long getTrackId() {
		return trackId;
	}

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public void setNode(Node node) {
        this.node = node;
    }


    public void setPlaces(Places places) {
        this.places = places;
    }

    public void setTrack(Track track) {
        this.track = track;
    }

    public void setTrackId(Long trackId) {
		this.trackId = trackId;
	}

    @Override
    public String toString() {
        return "pl.edu.agh.io.gpstracker.model.Tracksequence[id=" + id + "]";
    }

}
